package com.weekdo.moviecomic;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MainMenu extends BaseAdapter {
	private LayoutInflater mInflater;
	private String[] mThumbPathList;
	private String[] mComicNameList;
	private String[] mEntryList;

	public MainMenu(Context context, String[] thumbPathList, String[] comicNameList, String[] entryList) {
		mInflater = LayoutInflater.from(context);
		mThumbPathList = thumbPathList;
		mComicNameList = comicNameList;
		mEntryList = entryList;
	}
	
	public String getItemEntry(int position) {
		return mEntryList[position];
	}


	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mThumbPathList.length;
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	static class ViewHolder {
		TextView text;
	    ImageView icon;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null && mThumbPathList.length>0) {
			ViewHolder holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.menu_item, null);
			holder.text = (TextView)convertView.findViewById(R.id.text);
			holder.icon = (ImageView)convertView.findViewById(R.id.icon);
			
			holder.text.setText(mComicNameList[position]);
			Uri imgUri=Uri.parse(mThumbPathList[position]);
			holder.icon.setImageURI(imgUri);
		}

		return convertView;
	}


}